﻿using System;
using System.Windows.Browser;

namespace jLight.Extensions
{
    public static class jQueryExtensionManipulation
    {
        /// <summary>
        /// Create a copy of the set of matched elements.
        /// </summary>        
        public static jQueryObject Clone(this jQueryObject value)
        {
            return value.Invoke("clone");
        }
        /// <summary>
        /// Create a copy of the set of matched elements.
        /// </summary>
        /// <param name="withDataAndEvents">A Boolean indicating whether event handlers should be copied along with 
        /// the elements. As of jQuery 1.4 element data will be copied as well.
        ///</param>        
        public static jQueryObject Clone(this jQueryObject value, bool withDataAndEvents)
        {
            return value.Invoke("clone", withDataAndEvents);
        }

        /// <summary>
        /// Insert content, specified by the parameter, to the end of each element in the set of matched elements.
        /// </summary>
        /// <param name="content">An element, HTML string, or jQuery object to insert at the end of each element in 
        /// the set of matched elements.
        ///</param>
        public static jQueryObject Append(this jQueryObject value, string content)
        {
            return value.Invoke("append", content);
        }
        /// <summary>
        /// Insert content, specified by the parameter, to the end of each element in the set of matched elements.
        /// </summary>
        /// <param name="content">An element, HTML string, or jQuery object to insert at the end of each element in 
        /// the set of matched elements.
        ///</param>
        public static jQueryObject Append(this jQueryObject value, ScriptObject content)
        {
            return value.Invoke("append", content);
        }
        /// <summary>
        /// Insert content, specified by the parameter, to the end of each element in the set of matched elements.
        /// </summary>
        /// <param name="function">A function that returns an HTML string to insert at the end of each element 
        /// in the set of matched elements. Receives the index position of the element in the set and the old 
        /// HTML value of the element as arguments.
        ///</param>
        public static jQueryObject Append(this jQueryObject value, Func<object, object, object> function)
        {
            return value.Invoke("append", jQueryFunction.CreateCallback2(function));
        }

        /// <summary>
        /// Insert every element in the set of matched elements to the end of the target.
        /// </summary>
        /// <param name="content">A selector, element, HTML string, or jQuery object; the matched set of elements will be 
        /// inserted at the end of the element(s) specified by this parameter.
        ///</param>
        public static jQueryObject AppendTo(this jQueryObject value, string content)
        {
            return value.Invoke("appendTo", content);
        }
        /// <summary>
        /// Insert every element in the set of matched elements to the end of the target.
        /// </summary>
        /// <param name="content">A selector, element, HTML string, or jQuery object; the matched set of elements will be 
        /// inserted at the end of the element(s) specified by this parameter.
        ///</param>
        public static jQueryObject AppendTo(this jQueryObject value, ScriptObject content)
        {
            return value.Invoke("appendTo", content);
        }

        /// <summary>
        /// Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
        /// </summary>
        /// <param name="content">An element, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements.
        ///</param>
        public static jQueryObject Prepend(this jQueryObject value, string content)
        {
            return value.Invoke("prepend", content);
        }
        /// <summary>
        /// Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
        /// </summary>
        /// <param name="content">An element, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements.
        ///</param>
        public static jQueryObject Prepend(this jQueryObject value, ScriptObject content)
        {
            return value.Invoke("prepend", content);
        }
        /// <summary>
        /// Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
        /// </summary>
        /// <param name="function">A function that returns an HTML string to insert at the beginning of each 
        /// element in the set of matched elements. Receives the index position of the element in the set 
        /// and the old HTML value of the element as arguments.
        ///</param>
        public static jQueryObject Prepend(this jQueryObject value, Func<object, object, object> function)
        {
            return value.Invoke("prepend", jQueryFunction.CreateCallback2(function));
        }

        /// <summary>
        /// Insert every element in the set of matched elements to the beginning of the target.
        /// </summary>
        /// <param name="content">A selector, element, HTML string, or jQuery object; the matched 
        /// set of elements will be inserted at the beginning of the element(s) specified by this parameter.
        ///</param>
        public static jQueryObject PrependTo(this jQueryObject value, string content)
        {
            return value.Invoke("prependTo", content);
        }
        /// <summary>
        /// Insert every element in the set of matched elements to the beginning of the target.
        /// </summary>
        /// <param name="content">A  selector, element, HTML string, or jQuery object; the matched 
        /// set of elements will be inserted at the beginning of the element(s) specified by this parameter.
        ///</param>
        public static jQueryObject PrependTo(this jQueryObject value, ScriptObject content)
        {
            return value.Invoke("prependTo", content);
        }

        /// <summary>
        /// Get the combined text contents of each element in the set of matched elements, including their descendants
        /// </summary>       
        public static string Text(this jQueryObject value)
        {
            return value.Invoke<string>("text");
        }
        /// <summary>
        /// Set the content of each element in the set of matched elements to the specified text.
        /// </summary>        
        public static jQueryObject Text(this jQueryObject value, string text)
        {
            return value.Invoke("text", text);
        }
        /// <summary>
        /// Set the content of each element in the set of matched elements to the specified text.
        /// </summary>        
        public static jQueryObject Text(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("text", function);
        }
        /// <summary>
        /// Set the content of each element in the set of matched elements to the specified text.
        /// </summary>
        public static jQueryObject Text(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("text", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Get the HTML contents of the first element in the set of matched elements.
        /// </summary>       
        public static string Html(this jQueryObject value)
        {
            return value.Invoke<string>("html");
        }
        /// <summary>
        /// Set the HTML contents of each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Html(this jQueryObject value, string html)
        {
            return value.Invoke("html", html);
        }
        /// <summary>
        /// Set the HTML contents of each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Html(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("html", function);
        }
        /// <summary>
        /// Set the HTML contents of each element in the set of matched elements.
        /// </summary>
        public static jQueryObject Html(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("html", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
        /// </summary>       
        public static jQueryObject Unwrap(this jQueryObject value)
        {
            return value.Invoke("unwrap");
        }

        /// <summary>
        /// Wrap an HTML structure around each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Wrap(this jQueryObject value, string html)
        {
            return value.Invoke("wrap", html);
        }
        /// <summary>
        /// Wrap an HTML structure around each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Wrap(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("wrap", function);
        }
        /// <summary>
        /// Wrap an HTML structure around each element in the set of matched elements.
        /// </summary>
        public static jQueryObject Wrap(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("wrap", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Wrap an HTML structure around all elements in the set of matched elements.
        /// </summary>        
        public static jQueryObject WrapAll(this jQueryObject value, string html)
        {
            return value.Invoke("wrapAll", html);
        }
        /// <summary>
        /// Wrap an HTML structure around all elements in the set of matched elements.
        /// </summary>        
        public static jQueryObject WrapAll(this jQueryObject value, ScriptObject scriptObject)
        {
            return value.Invoke("wrapAll", scriptObject);
        }

        /// <summary>
        /// Wrap an HTML structure around the content of each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject WrapInner(this jQueryObject value, string html)
        {
            return value.Invoke("wrapInner", html);
        }
        /// <summary>
        /// Wrap an HTML structure around the content of each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject WrapInner(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("wrapInner", function);
        }
        /// <summary>
        /// Wrap an HTML structure around the content of each element in the set of matched elements.
        /// </summary>
        public static jQueryObject WrapInner(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("wrapInner", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Insert content, specified by the parameter, after each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject After(this jQueryObject value, string html)
        {
            return value.Invoke("after", html);
        }
        /// <summary>
        /// Insert content, specified by the parameter, after each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject After(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("after", function);
        }
        /// <summary>
        /// Insert content, specified by the parameter, after each element in the set of matched elements.
        /// </summary>
        public static jQueryObject After(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("after", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Insert content, specified by the parameter, before each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Before(this jQueryObject value, string html)
        {
            return value.Invoke("before", html);
        }
        /// <summary>
        /// Insert content, specified by the parameter, before each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Before(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("before", function);
        }
        /// <summary>
        /// Insert content, specified by the parameter, before each element in the set of matched elements.
        /// </summary>
        public static jQueryObject Before(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("before", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Insert content, specified by the parameter, after each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject InsertAfter(this jQueryObject value, string html)
        {
            return value.Invoke("insertAfter", html);
        }
        /// <summary>
        /// Insert content, specified by the parameter, after each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject InsertAfter(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("insertAfter", function);
        }
        /// <summary>
        /// Insert content, specified by the parameter, after each element in the set of matched elements.
        /// </summary>
        public static jQueryObject InsertAfter(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("insertAfter", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Insert content, specified by the parameter, before each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject InsertBefore(this jQueryObject value, string html)
        {
            return value.Invoke("insertBefore", html);
        }
        /// <summary>
        /// Insert content, specified by the parameter, before each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject InsertBefore(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("insertBefore", function);
        }
        /// <summary>
        /// Insert content, specified by the parameter, before each element in the set of matched elements.
        /// </summary>
        public static jQueryObject InsertBefore(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("insertBefore", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Remove the set of matched elements from the DOM.
        /// </summary>        
        public static jQueryObject Detach(this jQueryObject value, jQuerySelector selector)
        {
            return value.Invoke("detach", selector.ToString());
        }
        /// <summary>
        /// Remove the set of matched elements from the DOM.
        /// </summary>        
        public static jQueryObject Detach(this jQueryObject value)
        {
            return value.Invoke("detach");
        }

        /// <summary>
        /// Remove all child nodes of the set of matched elements from the DOM.
        /// </summary>        
        public static jQueryObject Empty(this jQueryObject value)
        {
            return value.Invoke("empty");
        }

        /// <summary>
        /// Remove the set of matched elements from the DOM.
        /// </summary>        
        public static jQueryObject Remove(this jQueryObject value, jQuerySelector selector)
        {
            return value.Invoke("remove", selector.ToString());
        }
        /// <summary>
        /// Remove the set of matched elements from the DOM.
        /// </summary>        
        public static jQueryObject Remove(this jQueryObject value)
        {
            return value.Invoke("remove");
        }

        /// <summary>
        /// Replace each target element with the set of matched elements.
        /// </summary>        
        public static jQueryObject ReplaceAll(this jQueryObject value, jQuerySelector selector)
        {
            return value.Invoke("replaceAll", selector.ToString());
        }

        /// <summary>
        /// Replace each element in the set of matched elements with the provided new content.
        /// </summary>        
        public static jQueryObject ReplaceWith(this jQueryObject value, string html)
        {
            return value.Invoke("replaceWith", html);
        }
        /// <summary>
        /// Replace each element in the set of matched elements with the provided new content.
        /// </summary>        
        public static jQueryObject ReplaceWith(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("replaceWith", function);
        }
        /// <summary>
        /// Replace each element in the set of matched elements with the provided new content.
        /// </summary>
        public static jQueryObject ReplaceWith(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("replaceWith", jQueryFunction.CreateCallback1(function));
        }

        /// <summary>
        /// Get the value of an attribute for the first element in the set of matched elements.
        /// </summary>        
        public static string Attr(this jQueryObject value, string attribute)
        {
            return value.Invoke<string>("attr", attribute);
        }
        /// <summary>
        /// Set one or more attributes for the set of matched elements.
        /// </summary>        
        public static jQueryObject Attr(this jQueryObject value, string attributeName, string attributeValue)
        {
            return value.Invoke("attr", attributeName, attributeValue);
        }
        /// <summary>
        /// Set one or more attributes for the set of matched elements.
        /// </summary>        
        public static jQueryObject Attr(this jQueryObject value, jQueryAttributeMap map)
        {
            return value.Invoke("attr", map.ScriptObject);
        }
        /// <summary>
        /// Set one or more attributes for the set of matched elements.
        /// </summary>        
        public static jQueryObject Attr(this jQueryObject value, string attributeName, Func<object, object, object> function)
        {
            return value.Invoke("attr", attributeName, jQueryFunction.CreateCallback2(function));
        }

        /// <summary>
        /// Remove an attribute from each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject RemoveAttr(this jQueryObject value, string attribute)
        {
            return value.Invoke("removeAttr", attribute);
        }

        /// <summary>
        /// Get the current value of the first element in the set of matched elements.
        /// </summary>       
        public static string Val(this jQueryObject value)
        {
            return value.Invoke<string>("val");
        }
        /// <summary>
        /// Set the value of each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Val(this jQueryObject value, string text)
        {
            return value.Invoke("val", text);
        }
        /// <summary>
        /// Set the value of each element in the set of matched elements.
        /// </summary>        
        public static jQueryObject Val(this jQueryObject value, ScriptObject function)
        {
            return value.Invoke("val", function);
        }
        /// <summary>
        /// Set the value of each element in the set of matched elements.
        /// </summary>
        public static jQueryObject Val(this jQueryObject value, Func<object, object> function)
        {
            return value.Invoke("val", jQueryFunction.CreateCallback1(function));
        }
    
    }
}